﻿<c:BaseControl x:Class="personalplaner.gui.stamm.views.PersonalStamm"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:v="clr-namespace:personalplaner.gui.stamm.views"
        xmlns:c="clr-namespace:personalplaner.common.controls;assembly=personalplaner.common"
        xmlns:bs="clr-namespace:personalplaner.business.stamm;assembly=personalplaner.business"
        xmlns:p="clr-namespace:personalplaner.gui.Properties"
        xmlns:vm="clr-namespace:personalplaner.common.mvvm.factory;assembly=personalplaner.common"
        xmlns:fac="clr-namespace:personalplaner.gui.stamm.viewmodels.factories"
        vm:ViewModelLoader.FactoryType="{x:Type fac:PersonalStammModelFactory}"
        Foreground="#E1000000">
    
<!--ShowInTaskbar="False"
        WindowStartupLocation="CenterOwner"
        WindowStyle="ToolWindow"
        Title="Personalstamm" Height="420" Width="800" Background="LightGray"-->

    <Control.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/personalplaner.common;component/resources/TabControlStyles.xaml"/>
                <ResourceDictionary Source="/personalplaner.common;component/resources/styles/WhiteStyleTemplates.xaml"/>
                <ResourceDictionary>
                    <DataTemplate DataType="{x:Type bs:Person}">
                        <Grid Margin="0,0,20,0">
                            <Grid.ColumnDefinitions>
                                <!--<ColumnDefinition Width="30"/>-->
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>

                            <Grid.OpacityMask>
                                <LinearGradientBrush StartPoint="0,0" EndPoint="1,1">
                                    <GradientStop Offset="0.0" Color="Black" />
                                    <GradientStop Offset="0.8" Color="Black" />
                                    <GradientStop Offset="1.0" Color="Transparent" />
                                </LinearGradientBrush>
                            </Grid.OpacityMask>

                            <!-- Create a trasparent border that keeps the width static -->
                            <Border Background="Transparent" Width="220" Grid.ColumnSpan="3"/>
                            
                            <TextBlock Name="txtPrsId" Text="{Binding PrsID}" Visibility="Collapsed"/>
                            <TextBlock Name="txtNachName" Text="{Binding Nachname}" Grid.Column="1" Margin="5,0,0,0"/>
                            <TextBlock Name="txtName" Text="{Binding Name}" Grid.Column="2" Margin="5,0,0,0"/>
                            
                        </Grid>

                        <DataTemplate.Triggers>
                            <DataTrigger Binding="{Binding PersonTyp}" Value="Zusatzperson">
                                <Setter TargetName="txtName" Property="Foreground" Value="Green"/>
                                <Setter TargetName="txtNachName" Property="Foreground" Value="Green"/>
                                <Setter TargetName="txtPrsId" Property="Foreground" Value="Green"/>
                            </DataTrigger>
                            <DataTrigger Binding="{Binding PersonTyp}" Value="Inaktiv">
                                <Setter TargetName="txtName" Property="Foreground" Value="Red"/>
                                <Setter TargetName="txtNachName" Property="Foreground" Value="Red"/>
                                <Setter TargetName="txtPrsId" Property="Foreground" Value="Red"/>
                            </DataTrigger>
                            
                            <DataTrigger Binding="{Binding ShowPrsId}" Value="True">
                                <Setter TargetName="txtPrsId" Property="Visibility" Value="Visible"/>
                            </DataTrigger>

                            <DataTrigger Binding="{Binding NameDisplay}" Value="VornameName">
                                <Setter TargetName="txtName" Property="Grid.Column" Value="1"/>
                                <Setter TargetName="txtNachName" Property="Grid.Column" Value="2"/>
                            </DataTrigger>
                            <!--<DataTrigger Binding="{Binding NameDisplay}" Value="NameVorname">
                                <Setter TargetName="txtNachName" Property="Grid.Column" Value="1"/>
                                <Setter TargetName="txtName" Property="Grid.Column" Value="2"/>
                            </DataTrigger>
                            <DataTrigger Binding="{Binding NameDisplay}" Value="NameV">
                                <Setter TargetName="txtNachName" Property="Grid.Column" Value="1"/>
                                <Setter TargetName="txtName" Property="Grid.Column" Value="2"/>
                            </DataTrigger>
                            <DataTrigger Binding="{Binding NameDisplay}" Value="Name">
                                <Setter TargetName="txtNachName" Property="Grid.Column" Value="1"/>
                                <Setter TargetName="txtName" Property="Grid.Column" Value="2"/>
                            </DataTrigger>-->

                        </DataTemplate.Triggers>

                    </DataTemplate>

                    <Style TargetType="{x:Type ItemsControl}" x:Key="borderedList">
                        <Setter Property="Foreground" Value="#E1000000"/>
                        <Setter Property="FontWeight" Value="Heavy"/>
                        <Setter Property="BorderBrush" Value="#E1000000"/>
                        <Setter Property="BorderThickness" Value="0,0,1,0"/>
                        <Setter Property="Background" Value="Transparent"/>
                    </Style>
                </ResourceDictionary>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Control.Resources>

    <Grid>
        
        <Grid.RowDefinitions>
            <RowDefinition />
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="220"/>
            <ColumnDefinition />
        </Grid.ColumnDefinitions>

        <Border BorderThickness="0" Background="Transparent" Margin="5,5,0,0">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition/>
                </Grid.RowDefinitions>
                <CheckBox Margin="8,4,0,5" IsChecked="{Binding ShowAllPersonen}">
                    <TextBlock Text="Alle Personen" />
                </CheckBox>
                <TextBox Grid.Row="1" FontSize="10" Text="{Binding FilterString, UpdateSourceTrigger=PropertyChanged}" FontWeight="Heavy" Margin="8,0,5,5"/>
                <ListBox Grid.Row="2" Margin="5,0,0,5" ItemsSource="{Binding Personen}" SelectedItem="{Binding ActiveGridItem}" ScrollViewer.HorizontalScrollBarVisibility="Disabled"/>
            </Grid>
        </Border>

        <GridSplitter Width="4" Background="Transparent"/>

        <TabControl Grid.Column="1" Margin="5,5,5,0" Style="{StaticResource BigTransparentTabControl}" ItemContainerStyle="{StaticResource BigTransparentMenuTabItem}">
            <TabItem Header="Personalien">
                <v:PersonalienView Margin="5" DataContext="{Binding Model.SelectedPerson}"/>
            </TabItem>
            <TabItem Header=" Erweiterte Informationen">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition />
                    </Grid.RowDefinitions>

                    <GroupBox Header="Pensum" Margin="2" >
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="230"/>
                                <ColumnDefinition />
                                <ColumnDefinition Width="130"/>
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto"/>
                            </Grid.RowDefinitions>

                            <TextBlock Text="Arbeitspensum in %"/>
                            <TextBox Grid.Column="1" Text="{Binding Model.Pensum.Prozent}" IsEnabled="False"/>

                            <TextBlock Text="Pensum von" Grid.Row="1"/>
                            <DatePicker Grid.Column="1" Grid.Row="1" SelectedDate="{Binding Model.Pensum.Von}" IsEnabled="False"/>

                            <TextBlock Text="Pensum bis" Grid.Row="2"/>
                            <DatePicker Grid.Column="1" Grid.Row="2" SelectedDate="{Binding Model.Pensum.Bis}" IsEnabled="False"/>
                            <Button Grid.Column="2" Grid.Row="2" Margin="10,0,10,0" Height="23" Command="{Binding SetPensumCommand}">
                                <TextBlock Text="Pensum ändern"/>
                            </Button>

                        </Grid>
                    </GroupBox>

                    <GroupBox Header="Anstellung" Margin="2" Grid.Row="1">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="230"/>
                                <ColumnDefinition />
                                <ColumnDefinition Width="130"/>
                            </Grid.ColumnDefinitions>

                            <TextBlock Text="{x:Static p:Resources.PersonAnstellungDescription}" TextWrapping="Wrap" VerticalAlignment="Top" Margin="0,3,10,0"/>
                            <TextBox Grid.Column="1" IsEnabled="False" Text="{Binding Model.Anstellung.Name}"/>
                            <Button Grid.Column="2" Margin="10,0,10,0" Height="23" 
                                    Command="{Binding SetAnstellungCommand}">
                                <TextBlock Text="Anstellung ändern"/>
                            </Button>

                        </Grid>
                    </GroupBox>

                    <GroupBox Header="Team" Margin="2" Grid.Row="2">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="230"/>
                                <ColumnDefinition />
                                <ColumnDefinition Width="130"/>
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                            </Grid.RowDefinitions>

                            <TextBlock Text="{x:Static p:Resources.PersonTeamDescription}" TextWrapping="Wrap" VerticalAlignment="Top" Margin="0,3,10,0"/>
                            <ItemsControl Grid.Column="1" MinHeight="60" Margin="1,3,1,1" Style="{StaticResource borderedList}"
                                     ItemsSource="{Binding Model.Abteilungen}"
                                     DisplayMemberPath="Name"/><!---->

                            <Button VerticalAlignment="Top" Grid.Column="2" Margin="10,3,10,0" Height="23" 
                                    Command="{Binding SetAbteilungCommand}">
                                <TextBlock Text="Bearbeiten"/>
                            </Button>

                        </Grid>
                    </GroupBox>
                    <GroupBox Header="Ferien" Margin="2" Grid.Row="3">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="230"/>
                                <ColumnDefinition />
                                <ColumnDefinition Width="Auto"/>
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                            </Grid.RowDefinitions>

                            <Button Grid.Row="7" HorizontalAlignment="Left" Margin="8,5,0,30" Command="{Binding HollidayCommand}">
                                <TextBlock Text="Ferienliste"/>
                            </Button>
                        </Grid>
                    </GroupBox>
                </Grid>
            </TabItem>
        </TabControl>

        <StackPanel Grid.Row="1" Grid.ColumnSpan="2" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,20,40,20">
            <Button MinWidth="60" Margin="5" 
                    Command="{Binding DeleteCommand}">
                <TextBlock Text="{x:Static p:Resources.Delete}"/>
            </Button>
            <Button MinWidth="60" Margin="5" 
                    Command="{Binding NewCommand}">
                <TextBlock Text="{x:Static p:Resources.New}"/>
            </Button>
            <Button MinWidth="60" Margin="5"
                    Command="{Binding SaveCommand}">
                <TextBlock Text="{x:Static p:Resources.Save}"/>
            </Button>
            <Button MinWidth="60" Margin="5" IsDefault="True" 
                    Command="{Binding OkCommand}">
                <TextBlock Text="{x:Static p:Resources.Ok}"/>
            </Button>
            <Button MinWidth="60" Margin="5" IsCancel="True" 
                    Command="{Binding CancelCommand}">
                <TextBlock Text="{x:Static p:Resources.Cancel}"/>
            </Button>
        </StackPanel>
    </Grid>
</c:BaseControl>
